<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0,user-scalable=0, width=device-width"/>
    <meta name="format-detection" content="telephone=no"/>
    <title>信号量列表</title>
    <link rel="stylesheet" type="text/css" href="../../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../../css/common.css" />
    <link rel="stylesheet" type="text/css" href="../../css/aui.css" />
    <link rel="stylesheet" href="../../script/ccssoft/css/ccssoft-lite.css" />
    <style>
		body {
          background-color: #eff1f0;
        }
    	 ul, li {
            margin: 0;
            padding: 0;
        }
        .ccssoft_list li {
            list-style: none;
            padding: 8px;
            border-bottom: 1px solid #e3e2e2;
            background: #fff;
            overflow: hidden;
            margin-bottom: 10px;
        }
        .ccssoft_list li:hover {
            background: #f9e9df;
        }
        
        .ccssoft_list li:active {
            background: #f9e9df;
        }
        
        .liTopLeft{
        	float:left;
        	width:15%;
        	height:40px;
        	line-height:40px;
        }
        .liTopRight{
        	float:left;
        	width:85%;
        	height:40px;
        }
        .liRightName{
        	width:100%;
        	height:20px;
        	line-height:20px;
        	text-align:left;
        	font-size:16px;
        	font-weight:bold;
        	white-space:nowrap;
        	overflow:hidden;
        	text-overflow:ellipsis;
        	padding-left:5px;
        }
        .liRightType{
        	width:100%;
        	height:20px;
        	line-height:20px;
        	text-align:left;
        	font-size:12px;
        	white-space:nowrap;
        	overflow:hidden;
        	text-overflow:ellipsis;
        	padding-left:5px;
        	color:#ADADAD;
        }
        .liRightDownCode{
        	float:left;
        	width:60%;
        	height:18px;
        	line-height:18px;
        	text-align:left;
        	color:#ADADAD;
        	font-size:12px;
        	padding-left:10px;
        	white-space:nowrap;
        	overflow:hidden;
        	text-overflow:ellipsis;
        }
        .liRightDownCount{
        	float:left;
        	width:40%;
        	height:18px;
        	line-height:18px;
        	text-align:left;
        	color:#ADADAD;
        	font-size:12px;
        	padding-left:15px;
        }       
        .liTop{
			width:100%;
			height:43px;
			padding-bottom:3px;
			border-bottom: 1px solid #e3e2e2;
		}		
		.liDown{
			width:100%;
			height:21px;
			padding-top:3px;
			font-size:12px;			
		}
    </style>
</head>
<body>
    <div id="main">
    
    	<script id="signalList-template" type="text/x-dot-template">
	        {{ for(var i=0, len=it.length; i < len; i++) { }}
	        	
	        <li tapmode="active"  onclick="openSignalDetail(this)" semaphoreId="{{=it[i].id}}" semaphorename="{{=it[i].semaphorename}}" measuredval="{{=it[i].measuredval}}">
    			<div class="liTop">
	    			<div class="liTopLeft">
	    				 <img src="../image/home_gv_contactor.png" width="40px" height="40px"/>		
	    			</div>
	    			<div class="liTopRight">
	    				<div class="liRightName">{{=it[i].semaphorename}}</div>
	    				<div class="liRightType">信号指标类型：{{=it[i].semaphoretype}}</div>    					
	    			</div>
    			</div>
    			<div class="liDown">
    				<div class="liRightDownCode">信号指标状态：{{=it[i].semaphorestatus}}</div>
	    			<div class="liRightDownCount">信号指标值：{{=it[i].measuredval}}</div>
    			</div>
    		</li>
	        {{ } }}
	    </script>
    	<ul class="ccssoft_list" id="signalList">    		
    		    		
    	</ul>
    </div>
</body>
<script src="../../script/jquery-1.11.3.min.js"></script>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/constant.js"></script>
<script type="text/javascript" src="../../script/debug.js"></script>
<script type="text/javascript" src="../../script/doT.min.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>
<script type="text/javascript" src="../../script/config.js"></script>
<script type="text/javascript" src="../../script/client.api.js"></script>
<script type="text/javascript" src="../../script/aui-alert.js"></script>
<script>
var start = 0;
var loadDone = false;
var showProgress = true;

function openSignalDetail(el) { 
    var semaphorename = $api.attr(el, 'semaphorename');
    var measuredval = $api.attr(el, 'measuredval');
    var semaphoreId = $api.attr(el, 'semaphoreId');
    api.pageParam.measuredval = measuredval;
    api.pageParam.semaphorename = semaphorename;
    api.pageParam.semaphoreId = semaphoreId;
    api.openWin({
        name: 'signalRealData',
        url: 'signalRealData.html',
        opaque: true,
        bounces: false,
        reload:true,
        pageParam: api.pageParam,
        vScrollBarEnabled: false
    });

}
function getSignalList() {
	if(api.pageParam.deviceCode != null){
//		var user = $api.getStorage('user');
//		var userid = user.userid;
		var devFsuId = api.pageParam.devFsuId;
		var showflag  = api.pageParam.showflag;
		var areaid = api.pageParam.stationId;
		var deviceCode = api.pageParam.deviceCode;
		var opts ={
			showflag:showflag,
			deviceCode:deviceCode,
			areaid:areaid,
			start:start
		};
		api.showProgress({
			title : '加载中',
			modal : false
		});
		$client.getSimpleOrAllSignalList(opts, function(ret, err) {
			if (ret) {
				if (ret.success) {
					//var strs = $api.jsonToStr(ret);
					//alert(strs);
					if(ret.list == null || ret.list.length<1){
						loadDone = true;
					}else{
						var content = $api.byId('signalList');
			            var tpl = $api.byId('signalList-template').text;
			            var tempFn = doT.template(tpl);
			            content.innerHTML = tempFn(ret.list);
					}
				} else {
					api.toast({msg: ret.data_info, location: 'middle'});
				}
			} else {
	            api.toast({msg: err.msg, location: 'middle'});
	        }
	        
	        if(start == 0){
	        	api.refreshHeaderLoadDone();
				api.parseTapmode();
	        }
	        window.setTimeout(function(){
				api.parseTapmode();
				api.hideProgress();
			},500);
		});
	}else{
		loadDone = true;
	}
}


apiready = function () {
    getSignalList();
    $(window).scroll(function(){
		if($(document).scrollTop()>=$(document).height()-$(window).height()){
			if(!loadDone){
	    		start += 1;
	    		showProgress = true;
	        	getSignalList();
	    	}
		}
	});
	
    api.setRefreshHeaderInfo({
        visible: true,
        bgColor: '#f2f2f2',
        textColor: '#4d4d4d',
        textDown: '下拉刷新...',
        textUp: '松开刷新...',
        showTime: true
    }, function (ret, err) {
		start = 0;
		loadDone = false;
		showProgress = false;
    	getSignalList();
    });
}
</script>
</html>
